﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Avatar.Model;
using AvatarHelper;

namespace Avatar.Company
{
    public static class ExpirationDateManager
    {
        /// <summary>
        /// 获取包月用户过期时间
        /// </summary>
        /// <param name="_company"></param>
        /// <returns></returns>
        public static string GetExpirationDate(string _company)
        {
            using(var _adc=DBHelper.GetDataContext())
            {
                var _exDate = _adc.CompanyMonthlyUserExpirationDate.FirstOrDefault(c => c.Company == _company);
                if (_exDate == null)
                {
                    return "<span style='color:Red;'>未设置</span>";
                }
                else
                {
                    if (_exDate.ExpirationDate.Subtract(DateTime.Today).Days < 5)
                    {
                        return "<span style='color:Red;'>"+_exDate.ExpirationDate.ToShortDateString()+"</span>";
                    }
                    else
                    {
                        return _exDate.ExpirationDate.ToShortDateString();
                    }
                }
            }
        }
    }
}
